home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_toolbx.arc / VIEW.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-03-30  |  1.2 KB  |  47 lines

  1. /* view.c - View program - main function  */
  2. #include "stdio.h"
  3. #include "cminor.h"
  4. #include "viewcmds.h"
  5. #include "viewparm.h"
  6.  
  7. char filename[65] = "" ;
  8.  
  9. main(argc,argv)
  10.   int     argc    ;
  11.   char    *argv[] ;
  12.   {
  13.     int cmd ;                /* holds current cmd        */
  14.  
  15.     if( argc <= 2 )            /* get file name from command    */
  16.       strcpy(filename,argv[1]) ;    /* line (if present)        */
  17.  
  18.     get_filename(filename) ;        /* get file name and open file    */
  19.     set_filesize(ASC_MODE) ;        /* set up file size variable    */
  20.     cmd = FIRSTPAGE  ;            /* force display of first page    */
  21.  
  22.     while( cmd != EXITPGM )        /* repeat until told to exit    */
  23.       { exec_cmd(cmd) ;         /* execute the current command    */
  24.     cmd  =    get_cmd() ;        /* get the next command     */
  25.       }
  26.  
  27.     close_file()  ;
  28.   }
  29.  
  30. int get_filename(fn)            /* get name of file and open it */
  31.   char    fn[]  ;             /* file name string        */
  32.   {                    /* filled out by caller     */
  33.     if( strlen(fn) == 0 )
  34.       { printf("File Name:") ;
  35.     scanf("%s",fn)  ;
  36.       }
  37.  
  38.   while( open_file(fn) == FAILURE )    /* open the file (verify name)    */
  39.     { printf("\n File - %s can not be opened\n",fn) ;
  40.       printf("File Name:") ;            /* try again                    */
  41.       scanf("%s",fn)  ;
  42.     }
  43.   }
  44.  
  45.  
  46.  
  47.